﻿Imports System.Data

Partial Class Default3
    Inherits System.Web.UI.Page


    Private dt As New DataTable()
    Private dr As DataRow = Nothing



    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        dt.Columns.Add("Product_Name")
        dt.Columns.Add("Product_Quantity")
        dt.Columns.Add("Product_Amount")
    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        If ViewState("table") IsNot Nothing Then
            dt = DirectCast(ViewState("table"), DataTable)
        End If
        dr = dt.NewRow()
        dr("Product_Name") = TextBox1.Text
        dr("Product_Quantity") = TextBox2.Text
        dr("Product_Amount") = TextBox3.Text
        dt.Rows.Add(dr)
        ViewState("table") = dt

        GridView1.DataSource = dt
        GridView1.DataBind()

        GridView2.DataSource = dt
        GridView2.DataBind()
    End Sub

    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        TextBox1.Text = "5555"
        GridView2.DataSource = dt
        GridView2.DataBind()
    End Sub
End Class
